<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/address-list.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">选择收货地址</h1>
		</header>
		<div class="mui-content" style="padding-top: 30px;">
			<ul class="mui-table-view" id="address-list">
				<li class="mui-table-view-cell" :class="{'active-bg-color':a.defaultAddress==1}" v-for="a in list" @click="selectAddress(a)">
					<span style="float: left;">收货人:{{a.receivePerson}}</span>
					<span style="float: right;">{{a.receivePhone}}<i v-show="a.defaultAddress==1" class="mui-icon mui-icon-checkmarkempty"></i></span>
					<p style="clear: both;" :class="{'actice-text-color':a.defaultAddress==1}">{{a.province}}{{a.city}}{{a.area}}{{a.detailedAddress}}</p>
				</li>
			</ul>
		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/const.js"></script>
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../js/address_service.js"></script>

		<script type="text/javascript">
			mui.init();

			//vue对象
			var address = new Vue({
				el: '#address-list',
				data: {
					list: [],
				},
				methods: {
					selectAddress: function(address) {
						var list = plus.webview.currentWebview().opener();
						//触发列表界面的自定义事件（refresh）,从而进行数据刷新  
						mui.fire(list, 'updateAddress', {
							address: address
						});
						mui.currentWebview.close();
					}
				}
			});

			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				//添加hide事件
				self.addEventListener('hide', function(e) {
					window.scrollTo(0, 0); //滚到顶部
					data_detail.resetData(); //数据重置
				}, false);
				plus.nativeUI.showWaiting('加载中', {
					width: '100px',
					height: '100px'
				});
				//获取接口数据
				var res = addressService.my_address_list();
				address.list = res.data;
				plus.nativeUI.closeWaiting();

			});
		</script>
	</body>

</html>